package homework;

import java.util.ArrayList;

public class Homework01 {
    @SuppressWarnings({"all"})
    public static void main(String[] args) {
        ArrayList arrayList = new ArrayList();
        arrayList.add(new News("英国可能会通过种族主义法案，民主、自由成了笑话"));
        arrayList.add(new News("警示性故事  城市如何充当私有和政治自治的经济区"));

        int size = arrayList.size();
        for (int i = size-1; i>=0 ; i--) {
            System.out.println(arrayList.get(i));
            News news = (News) arrayList.get(i);
            System.out.println(processTitle(news.getTitle()));
        }
    }

    public static String processTitle(String title){
        if (title == null){
            return " ";
        }
        if (title.length() > 15){
            return title.substring(0,15);//0-14
        }else {
            return title;
        }
    }
}

class News {
     private String title;
     private String content;

    public News(String title ) {
        this.title = title;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }
    public String getTitle() {
        return content;
    }

    public void setTitle(String content) {
        this.content = content;
    }

    @Override
    public String toString() {
        return "News{" +
                "title='" + title + '\'' +
                '}';
    }
}
